From 395e55d2224cddba41e397069ca9c3a6f4316422 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Tue, 18 Apr 2023 18:44:22 -0600 Subject: [PATCH] fix cppcheck constVariable warnings (#1070) * fix cppcheck constVariable warnings. * guard against qt container detachement. --- garmin_fit.cc | 2 +- gbser_posix.cc | 2 +- resample.cc | 3 +-- util.cc | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/garmin_fit.cc b/garmin_fit.cc index 8edb39584..0cc111d03 100644 --- a/garmin_fit.cc +++ b/garmin_fit.cc @@ -1248,7 +1248,7 @@ GarminFitFormat::fit_collect_track_tlr(const route_head* rte) fit_write_msg_event(track_date_time, kEventTimer, kEventTypeStart, 0); // Write track/course points for the whole track - for (auto& crpt: course) { + for (const auto& crpt: course) { if (crpt.is_course_point) { fit_write_msg_course_point(crpt.creation_time, crpt.lat, diff --git a/gbser_posix.cc b/gbser_posix.cc index 9cf9904e6..1ea54808e 100644 --- a/gbser_posix.cc +++ b/gbser_posix.cc @@ -186,7 +186,7 @@ int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity, gbser_handle* h = gbser_get_handle(handle); speed_t s; - static unsigned bit_flags[] = { + static const unsigned bit_flags[] = { 0, 0, 0, 0, 0, CS5, CS6, CS7, CS8 }; diff --git a/resample.cc b/resample.cc index 2b72ea0f5..251576b69 100644 --- a/resample.cc +++ b/resample.cc @@ -88,8 +88,7 @@ void ResampleFilter::average_waypoint(Waypoint* wpt, bool zero_stuffed) } counter = 0; if (global_opts.debug_level >= 5) { - for (auto& entry : history) { - auto [pos, avc, alt] = entry; + for (const auto& [pos, avc, alt] : qAsConst(history)) { qDebug() << "initial conditions" << pos << avc << alt; } qDebug() << "initial accumulator" << accumulated_position << accumulated_altitude_valid_count << accumulated_altitude; diff --git a/util.cc b/util.cc index ca7b2a4a4..9510543b7 100644 --- a/util.cc +++ b/util.cc @@ -570,7 +570,7 @@ le_write32(void* ptr, const unsigned value) time_t mkgmtime(struct tm* t) { - static int m_to_d[12] = + static const int m_to_d[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; short month = t->tm_mon; -- 2.30.2